package org.campuscontent.ui;

public class ZoomManager
{
    public ZoomManager()
    {
        this( 0.3, 5 );
    }
    
    public ZoomManager( double min, double max )
    {
        this.min = min; 
        this.max = max;
        
        current = 1;
        offset  = 0.3; 
    }
    
    public boolean zoomIn()
    {
        if ( current + offset <= max )
        {
            current += offset;
            return true;
        }
        
        return false;
    }
    
    public boolean zoomOut()
    {
        if ( current - offset >= min )
        {
            current -= offset;
            return true;
        }
        
        return false;
    }
    
    public void reset()
    {
        current = 1;
    }
    
    public double current()
    {
        return current;
    }
    
    public boolean canZoomIn()
    {
        return ( current + offset <= max );
    }
    
    public boolean canZoomOut()
    {
        return ( current - offset >= min );
    }
    
    protected double current;
    
    protected double min;
    protected double max;
    
    protected double offset;
}
